export default {
  namespaced: true,
  state: {
    username: sessionStorage.getItem('username'),
    userId: sessionStorage.getItem('userId'),
    token: sessionStorage.getItem('token')
  },
  getters: {
  },
  mutations: {
    loginMutation(state, user) {
      state.username = user.username;
      state.userId = user.userId;
      state.token = user.token;
    }
  },
  actions: {
    loginAction({ commit }, user) {
      commit('loginMutation', user);
      sessionStorage.setItem('username', user.username);
      sessionStorage.setItem('userId', user.userId);
      sessionStorage.setItem('token', user.token);
    }
  }
}
